package pattern;

import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * Created with IntelliJ IDEA.
 * Description:阻塞队列
 * User: 东莞呵呵
 * Date:2022-09-19
 * Time:17:40
 */
public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        BlockingDeque<Integer> blockingDeque=new LinkedBlockingDeque<>(100);
        //相比于offer put是具有阻塞作用
        blockingDeque.put(1);
        blockingDeque.put(2);
        blockingDeque.put(3);
        System.out.println(blockingDeque.take());
        System.out.println(blockingDeque.take());
        System.out.println(blockingDeque.take());
        //阻塞
        System.out.println(blockingDeque.take());

    }
}
